//
//  UIBarButtonItem + Category.swift
//  HJWeibo
//
//  Created by huangjiong on 16/2/1.
//  Copyright © 2016年 huangjiong. All rights reserved.
//

import UIKit

//创建类似OC中的分类
extension UIBarButtonItem
{
    //函数前加class,代理类方法
    class func createBarButtonItem(imageName imageName:String, target: AnyObject?, action: Selector) -> UIBarButtonItem
    {
        let btn = UIButton()
        btn.setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        btn.setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        btn.addTarget(target, action: action, forControlEvents: UIControlEvents.TouchUpInside)
        btn.sizeToFit()
        return UIBarButtonItem(customView: btn)
    }
}
